package com.fjw.car_send;

import android.graphics.RectF;

public class TouchArea {
    RectF rect;
    TouchAreaType type;
    int eventId;
    boolean touched;

    public TouchArea(float x, float y, float width, float height, TouchAreaType type) {
        this.rect = new RectF(x, y, x + width, y + height);
        this.type = type;
        this.eventId = -1;
        this.touched = false;
    }

    public boolean areaCheck(float x, float y, int eventId) {
        boolean in = rect.contains(x, y);
        if (in) {
            touched = true;
            this.eventId = eventId;
        }
        return in;
    }

    public boolean isTouched() {
        return touched;
    }

    public void release() {
        touched = false;
        eventId = -1;
    }

    public int getEventId() {
        return eventId;
    }

    
}
